package com.ybkj.o2o.zhuanche.common.query;

import org.apache.commons.lang.StringUtils;

/**
 * Created by YH on 16/10/25.
 */
public class CarTypeQuery {
  
  private Long carTypeId;
  
  private String typeName;
  
  private String serviceType;
  
  private Long companyId;
  
  private String companyName;
  
  private String appKey;

  private Integer page;

  private Integer rows;

  private Integer offset;
  
  public String getServiceType() {
    return serviceType;
  }

  public void setServiceType(String serviceType) {
    this.serviceType = serviceType;
  }

  public String getTypeName() {
    return typeName;
  }
  /**
   * 模糊查询.
   */
  
  public void setTypeName(String typeName) {
    if (StringUtils.isNotBlank(typeName)) {
      this.typeName = typeName;
    } else {
      this.typeName = null;
    }
  }

  public Long getCarTypeId() {
    return carTypeId;
  }

  public void setCarTypeId(Long carTypeId) {
    this.carTypeId = carTypeId;
  }

  public Long getCompanyId() {
    return companyId;
  }

  public void setCompanyId(Long companyId) {
    this.companyId = companyId;
  }

  public String getCompanyName() {
    return companyName;
  }
  /**
   * 模糊查询.
   */
  
  public void setCompanyName(String companyName) {
    if (StringUtils.isNotBlank(companyName)) {
      this.companyName = "%" + companyName + "%";
    } else {
      this.companyName = null;
    }
  }

  public String getAppKey() {
    return appKey;
  }

  public void setAppKey(String appKey) {
    this.appKey = appKey;
  }

  public Integer getPage() {
    return page;
  }

  public void setPage(Integer page) {
    this.page = page;
  }

  public Integer getRows() {
    return rows;
  }

  public void setRows(Integer rows) {
    this.rows = rows;
  }

  /**
   * 根据page和rows计算出偏移量.
   */
  public Integer getOffset() {
    if (getPage() == null || getRows() == null) {
      return null;
    }
    if (getPage() > 0) {
      return (getPage() - 1) * getRows();
    }

    return offset;
  }

  public void setOffset(Integer offset) {
    this.offset = offset;
  }

  @Override
  public String toString() {
    return "CarTypeQuery [carTypeId=" + carTypeId + ", companyId=" + companyId + ", companyName="
        + companyName + ", appKey=" + appKey + ", page=" + page + ", rows=" + rows + ", offset="
        + offset + "]";
  }

}
